<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <span th:include="~{include::mycss}"></span>
    <script>
        // $(function () {
        //     $(".btn-success").click(function () {
        //         $.ajax({
        //             url: "/buy",
        //             type: "get",
        //             data: {
        //                 "gid": $(this).val(),
        //             },
        //             success: function (data) {
        //                 alert(data);
        //             }
        //         })
        //     })
        // })
    </script>
</head>
<body>
         <div class="container">
<!--             <h4>欢迎<span th:text="${session.user.username} eq null ? '': ${session.user.username}"></span>登录。-->
             <a th:href="@{/logout}" class="btn btn-danger">注销</a>
             </h4>
             <hr>
             <table class="table table-bordered table-hover">
                <tr>
                  <td>商品名称</td>
                  <td>商品单价</td>
                  <td>商品描述</td>
                  <td>商品图片</td>
                  <td>商品库存</td>
                  <td>购买商品</td>
                </tr>
               <tr th:each="goods:${list}" th:object="${goods}">
                      <td th:text="*{gname}"></td>
                      <td th:text="*{price}"></td>
                      <td th:text="*{gdesc}"></td>
                      <td>
                          <img th:src="@{'/upload/'+*{pic}}" width="50px" height="50px">
                      </td>
                      <td th:text="*{amount}"></td>
                   <td>
                       <button class="btn btn-success" th:value="*{gid}" onclick="location='buy?gid='+value">加入购物车</button>
                   </td>
               </tr>
                 <tr>
                     <td colspan="6">
                         <button class="btn btn-info" onclick="location='showShopping'">查询购物车</button>
                         <button class="btn btn-info" onclick="location='showHistory'">查询历史购物记录</button>
                     </td>
                 </tr>
             </table>
         </div>
</body>
</html>
